package org.tank;

import java.awt.*;

/**
 * 子弹
 */
public class Bullet {
  public   int x=300;
  public   int y=300;
 public    int width,height=50;
    //子弹的移动速度
    public static  final int  speed=200;

    TankFram2 tankFram2=null;

    //是否还在存活
    public boolean isLive=true;

    public Bullet(int x, int y,int width,int height,TankFram2  tankFram2) {
        this.x = x;
        this.y = y;
        this.width=width;
        this.height=height;
         this.tankFram2=tankFram2;
    }

    public Bullet(){}

    public void fillRect(Graphics g) {
        Color color = g.getColor();
        g.setColor(Color.yellow);
        g.fillOval(x,y,width,height);
        g.setColor(color);
    }

    public void setMove(boolean isLeft,boolean isRight,boolean isUp,boolean isDown) {
            if(isLeft) x-=speed;
            if(isRight) x+=speed;
            if(isUp) y-=speed;
            if(isDown) y+=speed;
        if(x < 0 || y < 0 || x > tankFram2.GAME_WIDTH || y > tankFram2.GAME_HEIGHT) isLive = false;
    }
}
